from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator


class LoginRequiredMixin(object):
    

    @method_decorator(login_required(login_url='/login/'))
    def dispatch(self, request, *args, **kwargs):
        return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)

    # TODO dispatch 与 多继承 的区别是什么？
    # @classmethod
    # def as_view(cls, *args, **kwargs):

    #     # 通过 多继承的 父类 实现 返回视图函数
    #     view = super().as_view(*args, **kwargs)

    #     return login_required(view)
